
@REM parameters: <repo-file-name> <user> <password>

@setlocal

@REM parameters

@IF {%~3} == {} GOTO do_parameter_error
@IF NOT {%~4} == {} GOTO do_parameter_error

@REM create

@cd /D "%~dp0"
@cd ..\bin

@SET FOSSIL_EXEC=fossil

@"%FOSSIL_EXEC%" new -A %2 %1
@IF %ERRORLEVEL% neq 0 GOTO do_create_error

@"%FOSSIL_EXEC%" user password %2 %3 -R %1
@"%FOSSIL_EXEC%" setting autosync off -R %1
@"%FOSSIL_EXEC%" setting crnl-glob *, -R %1
@"%FOSSIL_EXEC%" setting encoding-glob *, -R %1

@exit /B 0

:do_parameter_error
@ECHO Usage: fossil-server-create-repo.bat ^<repo-file-name^> ^<user^> ^<password^>
@exit /B 1

:do_create_error
@ECHO Error: create failed
@exit /B 2
